package com.luyou.a02;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;

/**
 * 读取 BeanDefinition
 * @author 28336
 * @version 1.0
 * Create by 2023/12/7 9:02
 */
public class DefaultListableBeanFactoryTest {

    static class MyBean{}

    public static void main(String[] args) {
        //既实现了BeanFactory又实现了BeanDefinitionRegistry
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        //ClassPathBeanDefinitionScanner 的一种替代，编程式显式注册 bean
        AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(beanFactory);
        reader.register(MyBean.class);
        MyBean bean = beanFactory.getBean(MyBean.class);
        System.out.println(bean);
    }

}
